// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

import VirtualItem from "../../ui/VirtualItem";
import { VirtualArgs } from "../../ui/VirtualList";

const {ccclass, property} = cc._decorator;

export interface ThsItemArgs extends VirtualArgs {
    ts_code: string;
    name: string;
    upFloat: number, 
    tradeCount: number,
    childCount: number,
    totalMv: number,
}

@ccclass
export default class ThsPlateInfoItem extends VirtualItem<ThsItemArgs> {

    @property(cc.Label)
    textLabel: cc.Label = null;

    market: any = null;

    public onRefresh(args: ThsItemArgs) {
        let strData = (this.dataIdx + 1) + '';
        strData += '  ' + args.ts_code;
        strData += '  ' + args.name;
        strData += `  ${args.tradeCount}日涨幅:${args.upFloat}%`;
        strData += `  成分股数量:${args.childCount}个  总市值:${args.totalMv}`;
        this.textLabel.string = strData;
    }

    onClick () {
        if (this.market) {
            cc.director.emit('SelectThsPlateEvent', this.dataIdx);
        }
       
    }

    // update (dt) {}
}
